package com.example.a1.activity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.example.a1.R;
import com.example.a1.util.HttpUtil;

public class BannerDetailActivity extends AppCompatActivity {
    private TextView tvTitle, tvContent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_banner_detail); // 绑定布局

        // 初始化控件
        tvTitle = findViewById(R.id.banner_detail_title);
        tvContent = findViewById(R.id.banner_detail_content);

        // 获取跳转参数
        Intent intent = getIntent();
        String title = intent.getStringExtra("banner_title");
        String detailUrl = intent.getStringExtra("banner_detail_url");

        // 显示标题
        tvTitle.setText(title);

        // 加载详情内容
        loadBannerDetail(detailUrl);
    }

    // 加载轮播图对应的详情内容
    private void loadBannerDetail(String url) {
        HttpUtil.getBannerDetail(url, new HttpUtil.OnDataLoadedListener<String>() {
            @Override
            public void onSuccess(String data) {
                tvContent.setText(data); // 显示详情文本
            }

            @Override
            public void onFailure(String error) {
                Toast.makeText(BannerDetailActivity.this, "详情加载失败: " + error, Toast.LENGTH_SHORT).show();
            }
        });
    }
}